import request from "@/utils/request";

export const getContainerList = (instanceId: string) => {
    return request.get("/docker/container/list", {
        params: {
            "instanceId": instanceId
        }
    });
}

export const removeContainer = (instanceId: string, containerId: string) => {
    return request.post("/docker/container/remove", {
        'instanceId': instanceId,
        'containerId': containerId
    })
}

export const startContainer = (instanceId: string, containerId: string) => {
    return request.post("/docker/container/start", {
        'instanceId': instanceId,
        'containerId': containerId
    })
}

export const stopContainer = (instanceId: string, containerId: string) => {
    return request.post("/docker/container/stop", {
        'instanceId': instanceId,
        'containerId': containerId
    })
}

export const getInstanceList = () => {
    return request.get("/docker/instance/list");
}

export const getImageList = (instanceId: string) => {
    return request.get("/docker/image/list", {
        params: {
            'instanceId': instanceId
        }
    });
}

export const createExecute = (instanceId: string, containerId: string) => {
    return request.post("/docker/execute/create", {
        "instanceId": instanceId,
        "containerId": containerId
    })
}

export const startExecute = (instanceId: string, executeId: string) => {
    return request.post("/docker/execute/start", {
        "instanceId": instanceId,
        "executeId": executeId
    })
}

export const sendCommand = (instanceId: string, executeId: string, command: string) => {
    return request.post("/docker/execute/send", {
        "instanceId": instanceId,
        "executeId": executeId,
        "command": command
    })
}